﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AFei.PW_Manager.Config;
using AFei.PW_Manager.Config.Utility;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Protocols;

namespace AFei.PW_Manager.Api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        private IConfiguration _iConfiguration;
        public ValuesController(IConfiguration configuration)
        {
            _iConfiguration = configuration;
        }

        




        // GET api/values
        [HttpGet]
        public ActionResult<IEnumerable<string>> Get()
        {
            //var configHelper = new ConfigHelper(_iConfiguration);
            //var bbb = ConfigHelper.ConnectionType;
            //var aaa = _iConfiguration.GetValue<string>("ConnectionType");

            var httpContext = HttpContext;
             
            var myHttpContext = Utitlity.HttpContext.HttpContext.Current;

            var referenceEquals = ReferenceEquals(httpContext, myHttpContext);
            var eEquals = Equals(httpContext, myHttpContext);
            //var connectionType1=ConfigHelper.GetAppConfigByKey("ConnectionType");
            //var connectionType=ConfigHelper.GetAppConfigByKey<int>("ConnectionType");



            return new string[] { httpContext.ToString(), httpContext.ToString(),referenceEquals.ToString(),eEquals.ToString() };
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public ActionResult<string> Get(int id)
        {
            return "value";
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody] string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}
